package com.king.tv.dao.greendao.manager;

import android.util.Log;

import com.king.tv.App;
import com.king.tv.dao.greendao.dao.UserDao;

public class ManagerFactory {
    /**
     * 每一个BeanManager都管理着数据库中的一个表，我将这些管理者在ManagerFactory中进行统一管理
     */
    StudentManager studentManager;


    private static ManagerFactory mInstance = null;

    /**
     * 获取DaoFactory的实例
     *
     * @return
     */
    public static ManagerFactory getInstance() {
        if (mInstance == null) {
            synchronized (ManagerFactory.class) {
                if (mInstance == null) {
                    mInstance = new ManagerFactory();
                }
            }
        }
        return mInstance;
    }

    public synchronized StudentManager getStudentManager() {
        if (studentManager == null){
//            UserDao userDao = DaoManager.getInstance(App.getInstance()).getDaoSession().getUserDao();
//            Log.i("tag","==============UserDao"+userDao);
            studentManager = new StudentManager(DaoManager.getInstance(App.getInstance()).getDaoSession().getUserDao());
        }
        return studentManager;
    }

}
